package com.manager.devicemanager.util;


import com.alibaba.fastjson2.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.manager.devicemanager.entity.BoardDeviceInfo;

import java.io.IOException;

public class JsonToObjectConverter {
    private static final ObjectMapper objectMapper = new ObjectMapper();

    /**
     * 将 JSON 字符串转换为 BoardDeviceInfo 对象
     * @param json JSON 字符串
     * @return BoardDeviceInfo 对象
     * @throws IOException 转换失败时抛出异常
     */
    public static BoardDeviceInfo convertJsonToBoardDeviceInfo(String json)  {
        try {
            return  JSONObject.parseObject(json, BoardDeviceInfo.class);
//            return objectMapper.readValue(json, BoardDeviceInfo.class);
        } catch (Exception e) {
            e.printStackTrace();
            return new BoardDeviceInfo();
        }

    }
}